<template>
    <div class="home">
        <el-carousel :interval="4000" type="card" height="300px">
            <el-carousel-item v-for="(item, index) in banner" :key="index">
                <el-row>
                    <el-col :span="24">
                        <img ref="bannerHeight" :src="item.bannerPath" :alt="item.bannerName" @load="imgLoad" style="width: 100%">
                    </el-col>
                </el-row>
            </el-carousel-item>
        </el-carousel>
        <el-skeleton :loading="loading" animated :count="lists.length">
            <template #template>
                <div>
                    <el-skeleton-item variant="image" style="height:367px;" />
                    <div style="padding: 14px;">
                        <el-skeleton-item variant="h3" style="width: 50%;" />
                        <div style="display: flex; align-items: center; justify-items: space-between; margin-top: 16px; height: 16px;">
                            <el-skeleton-item variant="text" style="margin-right: 16px;" />
                            <el-skeleton-item variant="text" style="width: 30%;" />
                        </div>
                    </div>
                </div>
            </template>
            <template #default>
                <el-card :body-style="{ padding: '0px', marginBottom: '1px' }" v-for="item in lists" :key="item.name">
                    <img :src="item.imgUrl" class="image multi-content" />
                    <div style="padding: 14px;">
                        <span>{{ item.name }}</span>
                        <div class="bottom clearfix">
                            <span class="time">{{ currentDate }}</span>
                            <el-button type="text" class="button">操作按钮</el-button>
                        </div>
                    </div>
                </el-card>
            </template>
        </el-skeleton>
        <el-form ref="form" :model="form" label-width="80px">
            <el-form-item label="活动名称">
                <el-input v-model="form.name"></el-input>
            </el-form-item>
            <el-form-item label="活动区域">
                <el-select v-model="form.region" placeholder="请选择活动区域">
                <el-option label="区域一" value="shanghai"></el-option>
                <el-option label="区域二" value="beijing"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item label="活动时间">
                <el-col :span="11">
                <el-date-picker type="date" placeholder="选择日期" v-model="form.date1" style="width: 100%;"></el-date-picker>
                </el-col>
                <el-col class="line" :span="2">-</el-col>
                <el-col :span="11">
                <el-time-picker placeholder="选择时间" v-model="form.date2" style="width: 100%;"></el-time-picker>
                </el-col>
            </el-form-item>
            <el-form-item label="即时配送">
                <el-switch v-model="form.delivery"></el-switch>
            </el-form-item>
            <el-form-item label="活动性质">
                <el-checkbox-group v-model="form.type">
                <el-checkbox label="美食/餐厅线上活动" name="type"></el-checkbox>
                <el-checkbox label="地推活动" name="type"></el-checkbox>
                <el-checkbox label="线下主题活动" name="type"></el-checkbox>
                <el-checkbox label="单纯品牌曝光" name="type"></el-checkbox>
                </el-checkbox-group>
            </el-form-item>
            <el-form-item label="特殊资源">
                <el-radio-group v-model="form.resource">
                <el-radio label="线上品牌商赞助"></el-radio>
                <el-radio label="线下场地免费"></el-radio>
                </el-radio-group>
            </el-form-item>
            <el-form-item label="活动形式">
                <el-input type="textarea" v-model="form.desc"></el-input>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="onSubmit">立即创建</el-button>
                <el-button>取消</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script lang="ts">
import { Options, Vue } from 'vue-class-component';
import HelloWorld from '@/components/HelloWorld.vue'; // @ is an alias to /src
import { onMounted, defineComponent, Ref, ref, nextTick, reactive, toRefs } from 'vue';
interface NumberArray {
    color?: string,
    name?: string,
    [propName: string]:any
}
export default defineComponent({
    setup() {
        const bannerHeight = ref(null);
        const data:any = reactive({
            banner: [
                {
                    bannerPath: 'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2750049371,3060618668&fm=26&gp=0.jpg',
                    bannerName: '1212'
                },
                {
                    bannerPath: 'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2750049371,3060618668&fm=26&gp=0.jpg',
                    bannerName: '1212'
                },
                {
                    bannerPath: 'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=2750049371,3060618668&fm=26&gp=0.jpg',
                    bannerName: '1212'
                }
            ],
            loading: true,
            lists: [
                {
                    imgUrl: 'https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg',
                    name: '鹿'
                },
                {
                    imgUrl: 'https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg',
                    name: '马'
                },
                {
                    imgUrl: 'https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg',
                    name: '山狮'
                }
            ],
            currentDate: '2021-01-27 14:30:00'
        })
        const form: object = {
            name: '',
            region: '',
            date1: '',
            date2: '',
            delivery: false,
            type: [],
            resource: '',
            desc: ''
        }
        function onSubmit() {
           
        }
        onMounted(() => {
            setTimeout(() => {
                data.loading = false;
            }, 2000)
        })
        return {
            ...toRefs(data),
            form,
            onSubmit
        }
    }
})
</script>
<style lang="scss">
.el-carousel__item h3 {
    color: #475669;
    font-size: 14px;
    opacity: 0.75;
    line-height: 200px;
    margin: 0;
    width: 100%;
}
.el-carousel__item:nth-child(2n) {
    background-color: #99a9bf;
}
  
.el-carousel__item:nth-child(2n+1) {
    background-color: #d3dce6;
}
.image {
    width: 100%;
    height: 367px;
}
</style>